<template>
	<view class="pt10">
		<u-cell-item bg-color="#fff" :key="i" v-for="(x,i) in list" :title="x.title"
			:title-style="{fontSize:'30rpx',color:'#222'}" :value="x.amount"
			:value-style="{fontSize:'32rpx',color:x.status==-1?'#999':'#222'}" :label="x.create_time"
			:label-style="{fontSize:'24rpx',color:'#888'}"
			@click="$navTo('pages/assets/withdraw/detail',{id:x.id})"></u-cell-item>

		<view class="pt15 pb15">
			<u-empty text="亲，暂无相关数据" v-if="list.length==0 && loading=='nomore'" icon-size="200" font-size="28"
				margin-top="200"></u-empty>

			<u-loadmore v-else :status="loading" />
		</view>
	</view>
</template>

<script>
	import * as Api from '@/api/assets/index.js'
	export default {
		data() {
			return {
				page: 0,
				list: [],
				loading: 'loadmore'
			};
		},
		methods: {
			async getList() {
				if (this.loading == 'loading' || this.loading == 'nomore') return;
				this.loading = 'loading';
				const res = await Api.withdrawList(++this.page);
				if (res.data) {
					let {
						current_page,
						total,
						data,
					} = res.data;

					if (data) {
						this.page = current_page;
						this.list = this.list.concat(data)
					} else {
						this.list = []
						total = 0;
					}

					setTimeout(() => {
						if (this.list.length >= total) this.loading = 'nomore';
						else this.loading = 'loadmore';
					}, 500)
				}
			}
		},
		onReachBottom() {
			this.getList();
		},
		created() {
			this.getList();
		}
	}
</script>

<style lang="scss">

</style>